using MicroMsg.Resource.@string;
using MicroMsg.UI.Page;
using MicroMsg.UI.Util;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace MicroMsg.UI.UserContrl
{
	public class MMMessageBox : UserControl
	{
		private const int AlertView = 0;
		private const int TwoButtonView = 1;
		public const int UserClickBackKey = -1;
		public const int LeftButtonClickId = 0;
		public const int RightButtonClickId = 1;
		public const int CheckError = -1;
		public const int UserIsNotCheck = 0;
		public const int UserIsCheck = 1;
		private ModeDialogHelper mDlgHelper;
		internal ViewFlipper viewFliper;
		internal Grid AlertViewPanel;
		internal TextBlock AlertTxtMsgTxt;
		internal Button OkBtn;
		internal Grid TwoButtonViewPanel;
		internal TextBlock TwoButtonViewTitleTxt;
		internal Grid CustomCtrlContainer;
		internal TextBlock TwoButtonViewMsgTxt;
		internal CheckBox TwoButtonViewCheckBox;
		internal Button TwoButtonViewButton1;
		internal Button TwoButtonViewButton2;
		private bool _contentLoaded;
		public DlgReturnEvent ReturnEvent
		{
			set
			{
				this.mDlgHelper.DlgReturnCallBack = value;
			}
		}
		private MMMessageBox(bool isEnableBackKeyPress)
		{
			this.InitializeComponent();
			this.viewFliper.set_Background(R.theme.COMMON_APPBAR_BK_BRUSH);
			this.mDlgHelper = new ModeDialogHelper(this, isEnableBackKeyPress, (SolidColorBrush)Application.get_Current().get_Resources().get_Item("NearOpacityBrush1"), false);
		}
		public static MMMessageBox Show(string string_0, bool isEnableBackKeyPress = true, string strButton = "确定")
		{
			if ("确定" == strButton)
			{
				strButton = strings.COM_Confirm;
			}
			MMMessageBox mMMessageBox = new MMMessageBox(isEnableBackKeyPress);
			mMMessageBox.viewFliper.ShowView(0);
			mMMessageBox.AlertTxtMsgTxt.set_Text(string_0);
			mMMessageBox.OkBtn.set_Content(strButton);
			mMMessageBox.Show();
			return mMMessageBox;
		}
		private void Show()
		{
			this.mDlgHelper.Show();
		}
		private void Hide()
		{
			this.mDlgHelper.Hide(null);
		}
		public void Hide(int nExitKind = -1)
		{
			object object_ = nExitKind;
			DlgReturnEventArg dlgReturnEventArg_ = new DlgReturnEventArg(object_);
			this.mDlgHelper.Hide(dlgReturnEventArg_);
		}
		private void OK_Btn_Click(object sender, RoutedEventArgs e)
		{
			this.Hide();
		}
		public static MMMessageBox Show(string title, string string_0, bool isEnableBackKeyPress = true, string leftButtonName = "重试", string rightButtonName = "取消")
		{
			if ("重试" == leftButtonName)
			{
				leftButtonName = strings.COM_Retry;
			}
			if ("取消" == rightButtonName)
			{
				rightButtonName = strings.COM_Cancel;
			}
			MMMessageBox mMMessageBox = new MMMessageBox(isEnableBackKeyPress);
			mMMessageBox.viewFliper.ShowView(1);
			mMMessageBox.TwoButtonViewTitleTxt.set_Text(title);
			mMMessageBox.TwoButtonViewMsgTxt.set_Text(string_0);
			mMMessageBox.TwoButtonViewButton1.set_Content(leftButtonName);
			mMMessageBox.TwoButtonViewButton2.set_Content(rightButtonName);
			mMMessageBox.Show();
			return mMMessageBox;
		}
		public static MMMessageBox Show(string title, string string_0, int nButtonCount, bool isEnableBackKeyPress = true, string leftButtonName = "重试", string rightButtonName = "取消")
		{
			if ("重试" == leftButtonName)
			{
				leftButtonName = strings.COM_Retry;
			}
			if ("取消" == rightButtonName)
			{
				rightButtonName = strings.COM_Cancel;
			}
			MMMessageBox mMMessageBox = new MMMessageBox(isEnableBackKeyPress);
			if (nButtonCount == 0)
			{
				mMMessageBox.TwoButtonViewButton1.set_Visibility(1);
				mMMessageBox.TwoButtonViewButton2.set_Visibility(1);
			}
			else
			{
				if (1 == nButtonCount)
				{
					mMMessageBox.TwoButtonViewButton2.set_Visibility(1);
				}
			}
			mMMessageBox.viewFliper.ShowView(1);
			mMMessageBox.TwoButtonViewTitleTxt.set_Text(title);
			mMMessageBox.TwoButtonViewMsgTxt.set_Text(string_0);
			mMMessageBox.TwoButtonViewButton1.set_Content(leftButtonName);
			mMMessageBox.TwoButtonViewButton2.set_Content(rightButtonName);
			mMMessageBox.Show();
			return mMMessageBox;
		}
		public static MMMessageBox Show_Check(string title, string string_0, bool isEnableBackKeyPress = true, string checkName = "选项", bool checkBool = false, string leftButtonName = "重试", string rightButtonName = "取消")
		{
			if ("重试" == leftButtonName)
			{
				leftButtonName = strings.COM_Retry;
			}
			if ("取消" == rightButtonName)
			{
				rightButtonName = strings.COM_Cancel;
			}
			MMMessageBox mMMessageBox = new MMMessageBox(isEnableBackKeyPress);
			mMMessageBox.viewFliper.ShowView(1);
			mMMessageBox.TwoButtonViewTitleTxt.set_Text(title);
			mMMessageBox.TwoButtonViewMsgTxt.set_Text(string_0);
			mMMessageBox.TwoButtonViewButton1.set_Content(leftButtonName);
			mMMessageBox.TwoButtonViewButton2.set_Content(rightButtonName);
			mMMessageBox.TwoButtonViewCheckBox.set_Visibility(0);
			mMMessageBox.TwoButtonViewCheckBox.set_Content(checkName);
			mMMessageBox.TwoButtonViewCheckBox.set_IsChecked(new bool?(checkBool));
			mMMessageBox.Show();
			return mMMessageBox;
		}
		public static int GetUserClickResult(DlgReturnEventArg dlgReturnEventArg_0)
		{
			if (dlgReturnEventArg_0 == null || dlgReturnEventArg_0.mOtherArg == null)
			{
				return -1;
			}
			if (dlgReturnEventArg_0.mRet == Dlg_Result.Dlg_BackKey_Result)
			{
				return -1;
			}
			if ((int)dlgReturnEventArg_0.mOtherArg == 0)
			{
				return 0;
			}
			return 1;
		}
		public static int GetUserCheckResult(DlgReturnEventArg dlgReturnEventArg_0)
		{
			if (dlgReturnEventArg_0 == null || dlgReturnEventArg_0.mOtherArg == null || !dlgReturnEventArg_0.mChecked.get_HasValue())
			{
				return -1;
			}
			bool? mChecked = dlgReturnEventArg_0.mChecked;
			if (mChecked.GetValueOrDefault() && mChecked.get_HasValue())
			{
				return 1;
			}
			return 0;
		}
		private void TwoButtonViewButton1_Click(object sender, RoutedEventArgs e)
		{
			object object_ = 0;
			DlgReturnEventArg dlgReturnEventArg = new DlgReturnEventArg(object_);
			if (this.TwoButtonViewCheckBox.get_Visibility() == null && this.TwoButtonViewCheckBox.get_IsChecked().get_HasValue())
			{
				dlgReturnEventArg.setmCheck(this.TwoButtonViewCheckBox.get_IsChecked());
			}
			this.mDlgHelper.Hide(dlgReturnEventArg);
		}
		private void TwoButtonViewButton2_Click(object sender, RoutedEventArgs e)
		{
			object object_ = 1;
			DlgReturnEventArg dlgReturnEventArg_ = new DlgReturnEventArg(object_);
			this.mDlgHelper.Hide(dlgReturnEventArg_);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Util/MMMessageBox.xaml", 2));
			this.viewFliper = (ViewFlipper)base.FindName("viewFliper");
			this.AlertViewPanel = (Grid)base.FindName("AlertViewPanel");
			this.AlertTxtMsgTxt = (TextBlock)base.FindName("AlertTxtMsgTxt");
			this.OkBtn = (Button)base.FindName("OkBtn");
			this.TwoButtonViewPanel = (Grid)base.FindName("TwoButtonViewPanel");
			this.TwoButtonViewTitleTxt = (TextBlock)base.FindName("TwoButtonViewTitleTxt");
			this.CustomCtrlContainer = (Grid)base.FindName("CustomCtrlContainer");
			this.TwoButtonViewMsgTxt = (TextBlock)base.FindName("TwoButtonViewMsgTxt");
			this.TwoButtonViewCheckBox = (CheckBox)base.FindName("TwoButtonViewCheckBox");
			this.TwoButtonViewButton1 = (Button)base.FindName("TwoButtonViewButton1");
			this.TwoButtonViewButton2 = (Button)base.FindName("TwoButtonViewButton2");
		}
	}
}
